<template>
  <div class="goods_container">
    <input type="checkbox" :checked="state" @change="stateChange" />
    <img :src="imgUrl" alt="" />
    <div class="goodsInfo">
      <p class="goods_name">{{ goodsName }}</p>
      <div class="goods_pa">
        <div class="price">￥{{ goodsPrice }}</div>
        <slot></slot>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    id: {
      type: Number,
      require: true,
    },
    goodsName: {
      type: String,
      default: "",
    },
    goodsPrice: {
      type: Number,
      default: 888,
    },
    imgUrl: {
      type: String,
    },
    state: {
      type: Boolean,
    },
    num_g:{
      type:Number
    }
  },
  methods: {
    stateChange(e) {
      const newState = e.target.checked;
      this.$emit("stateChange", {
        id: this.id,
        value: newState,
      });
    },
  },
};
</script>
<style lang="less">
.goods_container {
  width: 100%;
  height: 150px;
  display: flex;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid #666;
  img {
    width: 125px;
    height: 125px;
    margin: 10px;
  }
  .goodsInfo {
    height: 125px;
    margin: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .goods_name {
      font-size: 12px;
    }
    .goods_pa {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .price {
        color: red;
      }
    }
  }
}
</style>